//
//  TeleViewController.m
//  盘盈贷
//
//  Created by iOS on 15/3/26.
//  Copyright (c) 2015年 Yunpeng Technologies. All rights reserved.
//

#import "TeleViewController.h"
#import "AFHTTPRequestOperationManager.h"
@interface TeleViewController ()
{
    UITextField *tele;
    UITextField *yam;
    UITextField *mima;
    
    
}
@end

@implementation TeleViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        self.title = @"手机绑定";
        
        self.view.backgroundColor = [UIColor whiteColor];
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    CGFloat height = self.view.frame.size.height;
    CGFloat width = self.view.frame.size.width;
    
    UILabel *youxianghao = [[UILabel alloc] initWithFrame:CGRectMake(10, height / 7, 80, 30)];
    youxianghao.text = @"号码 :";
    [self.view addSubview:youxianghao];
    [youxianghao release];
    
    
    
    tele = [[UITextField alloc] initWithFrame:CGRectMake(170, height / 5.7, 230, 30)];
    tele.center = CGPointMake(190, height / 5.7);
    tele.placeholder = @"请输入您的手机号";
    tele.textColor = [UIColor grayColor];
    tele.borderStyle = UITextBorderStyleRoundedRect;
    tele.clearButtonMode = UITextFieldViewModeWhileEditing;
    tele.borderStyle = UITextBorderStyleLine;
    [self.view addSubview:tele];
    [tele release];
    
    
    UIButton *test = [UIButton buttonWithType:UIButtonTypeSystem];
    test.frame = CGRectMake(118, height / 4.2, 120, 30);
    test.center = CGPointMake(135, height / 4.2);
    [test setTitle:@"发送验证码" forState:UIControlStateNormal];
    test.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
    test.backgroundColor = [UIColor redColor];
    [test setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [test addTarget:self action:@selector(test:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:test];
    
    UILabel *shou = [[UILabel alloc] initWithFrame:CGRectMake(10, height / 3.4, 80, 30)];
    shou.text = @"验证码:";
    [self.view addSubview:shou];
    [shou release];
    
    yam = [[UITextField alloc] initWithFrame:CGRectMake(170, height / 3.1, 230, 30)];
    yam.center = CGPointMake(190, height / 3.1);
    yam.placeholder = @"请填写验证码";
    yam.textColor = [UIColor grayColor];
    yam.borderStyle = UITextBorderStyleRoundedRect;
    yam.clearButtonMode = UITextFieldViewModeWhileEditing;
    yam.borderStyle = UITextBorderStyleLine;
    [self.view addSubview:yam];
    [yam release];
    
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(10, height / 2.2, 280, 35);
    button.center = CGPointMake(160, height / 2.2);
    button.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
    [button setTitle:@"确定" forState:UIControlStateNormal];
    button.backgroundColor = [UIColor redColor];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(next:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(removeKeyboard)];
    [self.view addGestureRecognizer:tap];
    
}
- (void)next:(id)sender {
    NSLog(@"telename:%@", self.name);
    NSString *str = [NSString stringWithFormat:@"http://www.cloudpeng.com:8102/audit/AuditEditMobile?phone=%@&username=%@", tele.text,self.name];
    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
   manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
    [manager GET:str parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        if ([responseObject isEqualToString:@"true"]) {
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"已绑定手机" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
            [alert show];
        }
       NSLog(@"issuccess:%@", responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"~~~~~~~%@",error);
    }];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
